<!--
Zeke Elder - zbe@andrew.cmu.edu
Amal Chemmany - achemman@andrew.cmu.edu
Nishant Kumar - nkumar1@andrew.cmu.edu
15-637
4/2/2012
-->
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<c:if test="${user == null}">
<c:redirect url="welcome.jsp"/>
</c:if>
<html>
<head>

<script src="js/fithub.js"></script>
		<link rel="stylesheet" href="./css/colorbox.css" />
		<script src="./js/jquery.min.js"></script>
		<script src="./js/jquery.colorbox.js"></script>
		<script>
			$(document).ready(function(){
				$(".iframe").colorbox();
				$(".callbacks").colorbox({
					iframe:true, width:"70%", height:"80%",
					onClosed:function(){ window.location.reload(); }
				});
				
			});
		</script>

<title>Welcome to FitHub!</title>
<link rel="stylesheet" type="text/css" href="css/style.css" />

</head>
<body>

	<!-- include header.jsp -->
	<jsp:include page="./header.jsp" flush="false" />
	<div class="body_container">
		<table>
			<tr>
				<td>
					<div class="newsfeed_title">News Feed</div> <br />
					<div align="center">
					 <a class='callbacks' href="showStory.do?postType=user&groupId=-1">Post a new story</a>
					</div> <br />
					<table>
						<c:forEach var="entry" items="${stories}">
							<div id="story1" class="story">
								[${entry.user.firstName} - ${entry.date}] ${entry.post} 
								<c:if test="${entry.user.userId == user.userId}">
									<input type="button" value="X" id="story1" onclick="window.location='deletePosts.do?postId=${entry.postId}'"/>
								</c:if>
							</div>
						<c:forEach var="commentEntry" items="${entry.comments}">
							<c:if test="${commentEntry != null}">
								<div id="story1_comment1" class="comment">
									[${commentEntry.user.firstName} - ${commentEntry.date}] ${commentEntry.comment} 
									<c:if test="${commentEntry.user.userId == user.userId}">
										<input type="button" value="X" id="story1" onclick="window.location='deleteComments.do?commentId=${commentEntry.commentId}'"/>
									</c:if>
								</div>
							</c:if>
						</c:forEach>
					 <a class='callbacks' href="showComment.do?postId=${entry.postId}">add comment</a>
						<hr>
						</c:forEach>
					</table>
				</td>
			</tr>
		</table>
		<br /> <br />
</body>
</html>